package com.ehotting.edsta.circuitDesign.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ehotting.edsta.circuitDesign.domain.EsCircuitCodeDataTemplate;
import com.ehotting.edsta.circuitDesign.service.IEsCircuitCodeDataTemplateService;
import com.ehotting.eaf.core.utils.poi.ExcelUtil;
import com.ehotting.eaf.core.web.controller.BaseController;
import com.ehotting.eaf.core.web.domain.AjaxResult;
import com.ehotting.eaf.core.web.page.TableDataInfo;
import com.ehotting.edsta.common.log.annotation.Log;
import com.ehotting.edsta.common.log.enums.BusinessType;
import com.ehotting.eaf.security.annotation.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 电路属性参数模板Controller
 * 
 * @author edsta
 * @date 2023-07-24
 */
@RestController
@RequestMapping("/template")
public class EsCircuitCodeDataTemplateController extends BaseController
{
    @Autowired
    private IEsCircuitCodeDataTemplateService esCircuitCodeDataTemplateService;

    /**
     * 查询电路属性参数模板列表
     */
//    //@PreAuthorize(hasPermi = "expert:dataTemplate:list")
    @GetMapping("/list")
    public TableDataInfo list(EsCircuitCodeDataTemplate esCircuitCodeDataTemplate)
    {
        startPage();
        List<EsCircuitCodeDataTemplate> list = esCircuitCodeDataTemplateService.selectEsCircuitCodeDataTemplateList(esCircuitCodeDataTemplate);
        return getDataTable(list);
    }

//    //@PreAuthorize(hasPermi = "expert:dataTemplate:allList")
    @GetMapping("/allList")
    public AjaxResult allList(EsCircuitCodeDataTemplate esCircuitCodeDataTemplate)
    {
        List<EsCircuitCodeDataTemplate> list = esCircuitCodeDataTemplateService.selectEsCircuitCodeDataTemplateList(esCircuitCodeDataTemplate);
        return AjaxResult.success(list);
    }

    /**
     * 导出电路属性参数模板列表
     */
    //@PreAuthorize(hasPermi = "expert:dataTemplate:export")
    @Log(title = "电路属性参数模板", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EsCircuitCodeDataTemplate esCircuitCodeDataTemplate) throws IOException
    {
        List<EsCircuitCodeDataTemplate> list = esCircuitCodeDataTemplateService.selectEsCircuitCodeDataTemplateList(esCircuitCodeDataTemplate);
        ExcelUtil<EsCircuitCodeDataTemplate> util = new ExcelUtil<EsCircuitCodeDataTemplate>(EsCircuitCodeDataTemplate.class);
        util.exportExcel(response, list, "电路属性参数模板数据");
    }

    /**
     * 获取电路属性参数模板详细信息
     */
    //@PreAuthorize(hasPermi = "expert:dataTemplate:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(esCircuitCodeDataTemplateService.selectEsCircuitCodeDataTemplateById(id));
    }

    /**
     * 新增电路属性参数模板
     */
    //@PreAuthorize(hasPermi = "expert:dataTemplate:add")
    @Log(title = "电路属性参数模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EsCircuitCodeDataTemplate esCircuitCodeDataTemplate)
    {
        return toAjax(esCircuitCodeDataTemplateService.insertEsCircuitCodeDataTemplate(esCircuitCodeDataTemplate));
    }

    /**
     * 修改电路属性参数模板
     */
    //@PreAuthorize(hasPermi = "expert:dataTemplate:edit")
    @Log(title = "电路属性参数模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EsCircuitCodeDataTemplate esCircuitCodeDataTemplate)
    {
        return toAjax(esCircuitCodeDataTemplateService.updateEsCircuitCodeDataTemplate(esCircuitCodeDataTemplate));
    }

    /**
     * 删除电路属性参数模板
     */
    //@PreAuthorize(hasPermi = "expert:dataTemplate:remove")
    @Log(title = "电路属性参数模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(esCircuitCodeDataTemplateService.deleteEsCircuitCodeDataTemplateByIds(ids));
    }
}
